namespace t0430 {
  /**
   * 调用者
   */
  class FunctionButton {
    private command!: Command;

    setCommand(command: Command): FunctionButton {
      this.command = command;
      return this;
    }
    click() {
      //调用命令类的方法
      this.command.Execute();
    }
  }
  /**
   * 抽象命令类
   */
  abstract class Command {
    Execute(): any {}
  }

  class Draw02Command extends Command {
    private seObj: Gpu; // = new SystemExitClass();
    constructor(re: Gpu) {
      super();
      this.seObj = re;
    }
    Execute() {
      this.seObj.Exit();
    }
  }

  /**
   * 接收者
   */
  class Gpu {
    //退出系统模拟实现类
    Exit() {
      console.log('退出系统！');
    }
  }
  class CommandMode {
    main() {
      let light = new Gpu();
      let command = new Draw02Command(light);
      let functionButton: FunctionButton = new FunctionButton().setCommand(command);
      functionButton.click(); //即在调用者调用时，命令对象操作接受者
    }
  }
}
